{{>licenseInfo}}

package {{package}};

{{#imports}}import {{import}};
{{/imports}}
import org.junit.Test;
import org.junit.Ignore;

{{#wiremock}}
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import java.net.HttpURLConnection;
import org.junit.AfterClass;
import org.junit.BeforeClass;
{{/wiremock}}

{{^fullJavaUtil}}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{/fullJavaUtil}}

{{#wiremock}}
import static com.github.tomakehurst.wiremock.client.WireMock.*;
{{/wiremock}}
/**
 * API tests for {{classname}}
 */
@Ignore
public class {{classname}}Test {

    private final {{classname}} api = new {{classname}}();
    {{#wiremock}}
    private static WireMockServer wireMockServer;

    public {{classname}}Test() {
        api.getApiClient().setBasePath("http://localhost:" + wireMockServer.port());
    }

    @BeforeClass
    public static void setUp() {
        wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig().dynamicPort());
        wireMockServer.start();

        configureFor(wireMockServer.port());
    {{#operations}}
    {{#operation}}
        stubFor({{#lowercase}}{{httpMethod}}{{/lowercase}}(urlPathMatching("{{{path}}}"))
                .willReturn(aResponse()
                        .withStatus(HttpURLConnection.HTTP_OK)));
    {{/operation}}
    {{/operations}}
    }

    @AfterClass
    public static void tearDown() {
        wireMockServer.stop();
    }
    {{/wiremock}}

    {{#operations}}{{#operation}}
    /**
     * {{summary}}
     *
     * {{notes}}
     *
     * @throws Exception
     *          if the Api call fails
     */
    @Test
    public void {{operationId}}Test() throws Exception {
        {{#allParams}}
        {{{dataType}}} {{paramName}} = null;
        {{/allParams}}
        {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});

        // TODO: test validations
    }
    {{/operation}}{{/operations}}
}
